package com.dx.as.lottie;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.airbnb.lottie.ImageAssetDelegate;
import com.airbnb.lottie.LottieImageAsset;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

/**
 * Created by jwaoo on 2018/3/5.
 */

public class MyImageAssetDelegate implements ImageAssetDelegate {

    private String dirPath;
    public MyImageAssetDelegate(String dirPath) {
        this.dirPath = dirPath;
    }

    @Override
    public Bitmap fetchBitmap(LottieImageAsset asset) {
        FileInputStream fis = null;
        Bitmap bitmap = null;
        try {
            fis = new FileInputStream(dirPath+"/"+asset.getFileName());
            bitmap  = BitmapFactory.decodeStream(fis);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return bitmap;
    }
}
